/*
 * Copyright (c) 2019 Author: Fancyears Milos Malvis @1243093366@qq.com
 * ALL COPYRIGHT REVERSED.
 */

package com.fancyears.service.i.user;

import com.alibaba.fastjson.JSONObject;
import com.fancyears.dto.UserLoginDTO;
import com.fancyears.model.user.User;
import com.fancyears.model.user.UserDetail;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @Author: fancyears·milos·malvis
 * @Description:
 * @Date: Created in  2019/5/8 10:45
 * @Modified By:
 */
public interface UserService {
    User getUser(Long id);

    /**
     * 插入1个有效的用户
     *
     * @param user
     * @return
     */
    boolean register(User user);

    /**
     * 将用户和用户详情一起插入
     *
     * @param user
     * @param userDetail
     * @return
     */
    boolean insertWithDetail(User user, UserDetail userDetail);

    /**
     * 使用cookie快速登录
     *
     * @param cookies
     * @return
     */
    boolean login(Cookie[] cookies);

    /**
     * 使用用户名和密码登录，密码可能要前端加密过
     *
     * @param u
     * @return
     */
    @Deprecated
    User login(User u);

    /**
     * 用户登录
     * @param user
     * @param request
     * @param response
     * @return
     */
    @Deprecated
    boolean doLogin(UserLoginDTO user, HttpServletRequest request, HttpServletResponse response);

    /**
     * 用户登录
     * @param user
     * @param request
     * @param response
     * @return
     */
    JSONObject doLogin2(UserLoginDTO user, HttpServletRequest request, HttpServletResponse response) throws IOException;

    JSONObject doSignout(HttpSession session);

    JSONObject insert(int id,int type);
}
